<template>
  <PullRefreshScrollLoadList
    :request="query.seaId == 'my' ? getMyList : getList"
    :dealQueryFun="(_query) => Object.assign(_query, query)"
    style="padding: 10px;"
    ref="pullRefreshScrollLoadList"
  >
    <template v-slot="list">
      <div class="card" v-for="(item, index) in list" :key="index" @click="cardClick(item)">
        <div v-if="item.leadsStatus == 0" class="card-new">new</div>
        <div class="card-custom flex">
          <!-- 头像 -->
          <!-- <img class="avatar" :src="item.avatar" alt /> -->

          <div class="custom-right">
            <div
              class="custom-name toe"
              v-html="
                query.name ? item.name.replace(query.name, `<span class='heighlight'>${query.name}</span>`) : item.name
              "
            ></div>

            <!-- 我的跟进线索中使用 -->
            <div class="custom-info" v-if="query.seaId == 'my'">
              <span class="key">{{ { 1: '领取', 2: '领取', 3: '退回' }[item.leadsStatus] }}时间</span>
              <span class="value">{{ item.updateTime }}</span>
            </div>

            <!-- 公海线索使用 -->
            <template v-else>
              <div class="custom-info" v-if="item.preFollowerName">
                <span class="key">前跟进人</span>
                <span class="value">{{ item.preFollowerName }}</span>
              </div>
              <div class="custom-info">
                <span class="key">{{ { 0: '投放', 3: '回收' }[item.leadsStatus] }}时间</span>
                <span class="value">{{ item.leadsStatus === 0 ? item.createTime : item.updateTime }}</span>
              </div>
            </template>
          </div>
        </div>

        <!-- 标签 -->
        <div class="card-tag" v-if="item.labelsNames">
          <div class="card-tag-item" v-for="(item1, i) in item.labelsNames.split(',').slice(0, 6)" :key="i">
            {{ item1 }}
          </div>
        </div>
      </div>
    </template>
  </PullRefreshScrollLoadList>
</template>

<script>
import { getList, getMyList } from '../api'
import { dateFormat } from '@/utils'
export default {
  components: {},
  props: {
    query: {
      type: Object,
      default: () => ({}),
    },
    isChange: {
      type: Boolean,
      default: false,
    },
  },
  watch: {
    // query: {
    //   handler(val) {
    //     this.getList(1)
    //   },
    //   // deep: true,
    //   // immediate: true,
    // },
  },
  data() {
    return {
      getList,
      getMyList,
      dateFormat,
    }
  },
  methods: {
    cardClick(item) {
      this.$router.push({
        name: 'clueDetail',
        query: { id: item.id, isDrainage: true },
      })
    },
  },
}
</script>

<style lang="less" scoped>
.card {
  position: relative;
  background: #ffffff;
  border-radius: 15px;
  padding: 20px 15px 15px 20px;
  overflow: hidden;
  & + & {
    margin-top: 10px;
  }

  .card-new {
    position: absolute;
    top: 0;
    right: -18px;
    width: 60px;
    height: 25px;
    background: #eaf0fd;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
    color: @color;
    line-height: 2.4;
    text-align: center;
    transform: rotate(45deg);
  }
  .avatar {
    width: 70px;
    height: 70px;
    border-radius: 8px;
  }
  .custom-right {
    display: flex;
    flex-direction: column;
    justify-content: space-evenly;
    // margin-left: 10px;
  }
  .custom-name {
    font-size: 14px;
    line-height: 20px;
    font-weight: 500;
    color: #001133;
    line-height: 20px;
  }
  ::v-deep .heighlight {
    color: @color;
  }

  .custom-info {
    margin-top: 8px;
    font-size: 12px;
    .key {
      color: #b5b8c0;
    }
    .value {
      margin-left: 10px;
      color: #5f6063;
    }
  }

  .card-tag {
    display: flex;
    flex-wrap: wrap;
    margin-top: 16px;
    gap: 10px;
    .card-tag-item {
      border-radius: 13px;
      background: #d3f2ff;
      line-height: 15px;
      padding: 5px 10px;
      font-size: 9px;
      font-weight: 400;
      color: @color;
    }
  }
}
</style>
